//package com.jsb.laundry.common.utils.job;
//
//import com.jsb.common.utils.JSBUtil;
//import com.jsb.dao.laundry.LaundryOrderDao;
//import com.jsb.utils.sf.SFMsgDataBuilder;
//import com.jsb.utils.sf.SFServiceCodeEnum;
//import com.jsb.utils.sf.SFUtil;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.scheduling.annotation.Async;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Service;
//
//import javax.annotation.Resource;
//import java.util.Arrays;
//import java.util.List;
//
//@Service
//@EnableScheduling
//public class SFService {
//
//    private static final Logger LOGGER = LoggerFactory.getLogger(SFService.class);
//
//    @Resource
//    private LaundryOrderDao laundryOrderDao;
//
//    /**
//     * 定时查询物流轨迹，如果已完成，调整订单状态为已完成
//     */
//
//    @Async("myAsync")
//    //    @Scheduled(fixedRate = 1000 * 10) //每10秒执行一次
//    @Scheduled(cron = "0 0 2 * * ?") // 每天凌晨2点执行
//    public void testScheduleTask() {
//        LOGGER.info("顺丰定时异步任务------查询物流轨迹------开始");
//        List<String> payIdList = laundryOrderDao.getBackOrderId();
//        if (JSBUtil.isEmptyCollection(payIdList)) {
//            LOGGER.info("暂未有要更新状态的顺丰订单");
//            return;
//        }
//        if (payIdList.size() > 3000) {
//            payIdList = payIdList.subList(0, 3000);
//        }
//
//        for (String backPayId : payIdList) {
//            List<String> id = Arrays.asList(backPayId);
//            String logisticsTrackMsgData = SFMsgDataBuilder.getLogisticsTrackMsgData(id);
//            String sfResponse = SFUtil.SFRequest(SFServiceCodeEnum.EXP_RECE_SEARCH_ROUTES.name(), logisticsTrackMsgData);
//            String opCode = SFUtil.getSFLogisticsTrack(sfResponse);
//            if ("8000".equals(opCode)) { //顺丰订单已完成,更新订单完成状态
//                laundryOrderDao.updOrderLastTime(backPayId);
//                LOGGER.info("backPayId:{},订单已完成", backPayId);
//            } else {
//                LOGGER.info("backPayId:{},订单还在配送中", backPayId);
//            }
//        }
//        LOGGER.info("顺丰定时异步任务------查询物流轨迹------结束");
//    }
//}
